<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <header th:replace="header::html"></header>
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>文章简介</legend>
</fieldset>
<blockquote class="layui-elem-quote" th:text="${summary}">这个貌似不用多介绍，因为你已经在太多的地方都看到</blockquote>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>文章内容</legend>
</fieldset>
<fieldset class="layui-elem-field">
    <div class="layui-field-box" th:text="${ArticleBody.content}">
    </div>
</fieldset>
<br>

<label class="layui-form-label">文章状态</label>
<div class="layui-field-box" th:text="${Tags}">
</div>


<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>文章审核</legend>
</fieldset>
<form class="layui-form" action="">
    <input type="text" id="articleId" th:value="${ArticleDto.articleId}" name="articleId" style="display:none;" autocomplete="off" class="layui-input">
    <div class="layui-form-item">
        <label class="layui-form-label">文章权重</label>
        <div class="layui-input-inline">
            <input type="text" name="weight" th:value="${ArticleDto.weight}" required lay-verify="weight" placeholder="请在这输入权重" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit  lay-filter="article-weight" style="margin-left: 40px">
            <i class="layui-icon layui-icon-search"></i>
            通过
        </button>
        <button type="reset" class="pear-btn pear-btn-md" lay-submit lay-filter="article-delete" >
            <i class="layui-icon layui-icon-refresh"></i>
            不通过
        </button>
    </div>

</form>

<script>
    layui.use(['form','jquery'],function(){
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(article-weight)', function(data){
            console.log(data.field.weight)
            $.ajax({
                url:'/api/article/verify/pass',
                data:JSON.stringify(data.field),
                dataType:'json',
                contentType:'application/json',
                type:'put',
                success:function(result){
                    if(result.success){
                        layer.msg(result.msg,{icon:1,time:1000},function(){
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("article-table");
                        });
                    }else{
                        layer.msg(result.msg,{icon:2,time:1000});
                    }
                }
            })
            return false;
        });
        form.verify({
            weight:  [
                /^[1-9]\d*$/
                ,'只能是整数哦'
            ],
        })
    })
</script>
</body>
</html>
